﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <title>StockBillPage</title>
    <script src="/Scripts/Common/jquery-1.8.3.min.js" type="text/javascript"></script>
    <script src="/Scripts/Common/Common.js" type="text/javascript"></script>
    <script src="/Scripts/Common/json2.js" type="text/javascript"></script>
    <script src="/Scripts/Common/jquery-barcode-2.0.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            var mStockBillObj;
            var mEviObj;
            var args = getUrlArgs();
            var stockBillId = args["StockBillId"];
            var msBillType = parseInt(args["mStockBillType"]);
            setBillTypeFeature(msBillType);
            $.ajax({
                url: "/Case/LoadStockBill",
                type: "POST",
                dataType: "json",
                async: false,
                data: { "stockBillId": stockBillId },
                success: function (req) {
                    if (req.IsSuccess) {
                        mStockBillObj = JSON.parse(req.Bill);
                        mEviObj = eval(req.Details);
                        FillInBillInfoBlank(mStockBillObj);
                        FillInEviInfoBlank(mEviObj);
                        //CreateBarCodeBySerialNo(mStockBillObj.SerialNo, msBillType);
                    }
                },
            });
        });
        function FillInBillInfoBlank(stockBillObj) {
            $('#lblydbh').text(stockBillObj.SourceSerialNo);
            $('#lbldjbh').text(stockBillObj.SerialNo);
            if (stockBillObj.StockType != undefined && stockBillObj.StockType != null) {
                $('#lblcrklx').text(stockBillObj.StockType.Name);
            }
            $('#lblajbh').text(stockBillObj.Number);
            $('#lblajlx').text(stockBillObj.Category.Name);
            $('#lblbadw').text(stockBillObj.TransferDept.Name);
            $('#lblbary').text(stockBillObj.TransferName);
            $('#lbllxfs').text(stockBillObj.TransferPhone);
            $('#lblbgbm').text(stockBillObj.ManageDept.Name);
            $('#lblbzsm').text(stockBillObj.Description);
            $('#lblzdbm').text(stockBillObj.TransferDept.Name);
            $('#lblzdry').text(stockBillObj.TransferName);
            //$('#lblzdsj').text(gFormatDateFormCSharp(stockBillObj.BillTime));
            if (stockBillObj.IsCheck) {
                $('#lblshdw').text(stockBillObj.ManageDept.Name);
                $('#lblshry').text(stockBillObj.Preparer.Name);
                $('#lblshsj').text(gFormatDateFormCSharp(stockBillObj.CheckTime));
            }
        };
        function FillInEviInfoBlank(eviObj) {
            var innerhtml = '<tr style="height: 30px"><td colspan="7" style="text-align: left; font: bold 20px 微软雅黑 100"><label>涉案物品列表</label></td></tr>';
            innerhtml += '<tr style="height: 30px"><td></td><td><label>类型</label></td><td><label>名称</label></td><td><label>型号</label></td><td>';
            innerhtml += '<label>数量</label></td><td><label>金额</label></td><td><label>仓位</label></td></tr>';
            if (eviObj.length == 0) {
                innerhtml += '<tr><td colspan="7">无相关涉案物品</td></tr>';
            } else {
                for (var i = 0; i < eviObj.length; i++) {
                    innerhtml += '<tr style="height: 30px">';
                    innerhtml += '<td>' + (i + 1) + '</td><td>' + eviObj[i].Evidence.EvidenceType.Name + '</td><td>' + eviObj[i].Evidence.Name + '</td><td>' + eviObj[i].Evidence.Model + '</td>';
                    var stroge = eviObj[i].Storage ? eviObj[i].Storage.FullName : null;
                    innerhtml += '<td>' + eviObj[i].Qty + '</td><td>' + eviObj[i].Amount + '</td><td>' + stroge + '</td>';
                    innerhtml += '</tr>';
                }
            }
            innerhtml += '<tr><td colspan="7"></td></tr>';
            $("#tbEvidences").html(innerhtml);
        };

        function setBillTypeFeature(billType) {
            $('#lblbillTypeName').text(gGetBillTypeName(billType));

            if (billType == 2 || billType == 4) {
                $('#lblbadwlogo').text("办案单位:");
                $('#lblbarylogo').text("办案人员:");
            } else if (billType == 3 || billType == 5) {
                $('#lblbadwlogo').text("调用单位:");
                $('#lblbarylogo').text("调用人员:");
            }

        };

        function CreateBarCodeBySerialNo(serialNo, billType) {
            if (serialNo == undefined || serialNo == "") {
                $("#barcodeTarget").html("生成条码失败");
            } else {
                var values = "";
                switch (billType) {
                    case 2:
                        values = "02" + serialNo.substring(2, serialNo.length);
                        break;
                    case 3:
                        values = "03" + serialNo.substring(3, serialNo.length);
                        break;
                    case 4:
                        values = "04" + serialNo.substring(2, serialNo.length);
                        break;
                    case 5:
                        values = "05" + serialNo.substring(3, serialNo.length);
                        break;
                };
                var btype = "ean13";
                var settings = {
                    output: "css",
                    bgColor: "#FFFFFF",
                    color: "#000000",
                    barWidth: 1,
                    barHeight: 40,
                    moduleSize: 5,
                    posX: 10,
                    posY: 20,
                    addQuietZone: 1
                };
                $("#barcodeTarget").html("").show().barcode(values, btype, settings);
            }
        };
    </script>
</head>
<body>
    <div>
        <table style="width: 100%; height: 200px; border: 1px solid black; border-bottom: 0px; border-collapse: collapse" border="1">
            <tr style="height: 50px">
                <td colspan="6" style="text-align: center; font: bold 30px 微软雅黑 100; border-right: 0px">
                    <label id="lblbillTypeName"></label>
                </td> 
            </tr>
            <tr>
                <td style="width: 100px; text-align: center">
                    <label>源单编号:</label>
                </td>
                <td>
                    <label id="lblydbh"></label>
                </td>
                <td style="width: 100px; text-align: center">
                    <label>单据编号:</label></td>
                <td>
                    <label id="lbldjbh"></label>
                </td>
                <td style="width: 100px; text-align: center">
                    <label>出/入库类型:</label>
                </td>
                <td>
                    <label id="lblcrklx"></label>
                </td>
            </tr>
            <tr>
                <td style="width: 100px; text-align: center">
                    <label>案件编号:</label></td>
                <td>
                    <label id="lblajbh"></label>
                </td>
                <td style="width: 100px; text-align: center">
                    <label>案件类型:</label></td>
                <td>
                    <label id="lblajlx"></label>
                </td>
                <td style="width: 100px; text-align: center">
                    <label>保管部门:</label></td>
                <td>
                    <label id="lblbgbm"></label>
                </td>
            </tr>
            <tr>
                <td style="width: 100px; text-align: center">
                    <label id="lblbadwlogo"></label>
                </td>
                <td>
                    <label id="lblbadw"></label>
                </td>
                <td style="width: 100px; text-align: center">
                    <label id="lblbarylogo"></label>
                </td>
                <td>
                    <label id="lblbary"></label>
                </td>
                <td style="width: 100px; text-align: center">
                    <label>联系方式:</label></td>
                <td>
                    <label id="lbllxfs"></label>
                </td>
            </tr>
            <tr>
                <td style="width: 100px; text-align: center">
                    <label>备注说明:</label></td>
                <td colspan="5">
                    <label id="lblbzsm"></label>
                </td>
            </tr>
            <tr>
                <td colspan="6"></td>
            </tr>
        </table>
        <table id="tbEvidences" style="width: 100%; height: 300px; text-align: center; border: 1px solid black; border-bottom: 0px; border-collapse: collapse" border="1">
        </table>
        <table style="width: 100%; height: 60px; border: 1px solid black; border-collapse: collapse" border="1">
            <tr>
                <td colspan="6"></td>
            </tr>
            <tr>
                <td style="width: 100px; text-align: center">
                    <label>办案单位:</label></td>
                <td>
                    <label id="lblzdbm"></label>
                </td>
                <td style="width: 100px; text-align: center">
                    <label>办案人员:</label></td>
                <td>
                    <label id="lblzdry"></label>
                </td>
                <td>
                    </td>
                <td>
                    
                </td>
            </tr>
            <tr>
                <td style="width: 100px; text-align: center">
                    <label>保管部门:</label></td>
                <td>
                    <label id="lblshdw"></label>
                </td>
                <td style="width: 100px; text-align: center">
                    <label>保管人员:</label></td>
                <td>
                    <label id="lblshry"></label>
                </td>
                <td style="width: 100px; text-align: center">
                    <label>保管时间:</label></td>
                <td>
                    <label id="lblshsj"></label>
                </td>
            </tr> 
        </table>
<br />
<p style="float:right"><label style="width:150px;">保管人员签字：__________________</label><label style="width:150px;">　　　　　　办案人员签字：___________________</label></p>
    </div>
</body>
</html>
